import 'package:flutter_screenutil/screenutil.dart';
import 'package:flutter/material.dart';
import 'package:heyangkuaidai/DemonStrateModule/Components/NavigationBar.dart';
import 'package:heyangkuaidai/DemonStrateModule/Components/InputWidget.dart';
import 'package:heyangkuaidai/DemonStrateModule/HomePage.dart';
class LoginPage extends StatefulWidget {
  @override
  _LoginPageState createState() => _LoginPageState();
}

class _LoginPageState extends State<LoginPage> {
   String account ;
   String password;
   bool _switchValue1 = false;
   @override
  void initState() {
    // TODO: implement initState
    super.initState();
    account ='';
    password ='';
  }
  @override
  Widget build(BuildContext context) {
    ScreenUtil.init(context, width: 375, height: 667, allowFontScaling: true);
    return Scaffold(
      resizeToAvoidBottomInset: false,
       body:Column(
         children: [
           SizedBox(height: MediaQuery.of(context).padding.top,),
           // NavigationBar(false,title: "登录",isShowBack: false,),
           SizedBox(height: ScreenUtil().setWidth(50),),
           Container(
             width: ScreenUtil().setWidth(180),
             height: ScreenUtil().setWidth(140),
             child:Image.asset("sources/yy/loginLogo.png",),
           ),
           SizedBox(height: ScreenUtil().setWidth(36),),
           Row(
             children: [
               SizedBox(width: ScreenUtil().setWidth(27),),
                // Container(
                //    width: ScreenUtil().setWidth(18),
                //    height: ScreenUtil().setWidth(18),
                //    child:Image.asset("sources/yy/account.png",),
                // ),
                // SizedBox(width: ScreenUtil().setWidth(8),),
                Stack(
                  children: [
                    Container(
                      width: ScreenUtil().setWidth(320),
                      child: InputWidget("手机号/卡号",width:ScreenUtil().setWidth(320),numlines:1,maxlength:11,finishCallback: (text){
                        account =text;
                      },borderColor:Color(0x19000000),selectBorderColor: Colors.blue,textAlignment: TextAlign.right,fontSize: 13,),
                    ),
                    Positioned(
                        top: ScreenUtil().setWidth(16),
                        left: 0,
                        child: Container(child: Text("登录号",style: TextStyle(fontSize: ScreenUtil().setSp(15),),textAlign: TextAlign.center),)
                    ),
                  ],
                )
             ],
           ),
           SizedBox( height: ScreenUtil().setWidth(20),),
           Row(
             children: [
               SizedBox(width: ScreenUtil().setWidth(27),),
               // Container(
               //   width: ScreenUtil().setWidth(18),
               //   height: ScreenUtil().setWidth(18),
               //   child:Image.asset("sources/yy/password.png",),
               // ),
               // SizedBox(width: ScreenUtil().setWidth(8),),
               Stack(
                 children: [
                   Container(
                     width: ScreenUtil().setWidth(320),
                     child: InputWidget("请输入登录密码",width:ScreenUtil().setWidth(320),numlines:1,maxlength:11,finishCallback: (text){
                       password = text;
                     },
                         obscureText: true,
                         borderColor:Color(0x19000000),
                         selectBorderColor: Colors.blue,
                         textAlignment: TextAlign.right,
                       fontSize: 13,
                     ),
                   ),
                   Positioned(
                       top: ScreenUtil().setWidth(16),
                       left: 0,
                       child: Container(child: Text("密码",style: TextStyle(fontSize: ScreenUtil().setSp(15),),textAlign: TextAlign.center),)
                   ),

                 ],
               )

             ],
           ),
           SizedBox(height: ScreenUtil().setWidth(10),),
           Row(
             children: [
               SizedBox(width: ScreenUtil().setWidth(27),),
                  Container(
                    child:Text("忘记密码?",style: TextStyle(fontSize: ScreenUtil().setSp(13),color: Colors.grey),textAlign: TextAlign.center),
                  ) ,
                 SizedBox(width: ScreenUtil().setWidth(207),),
                 Container(
                     child:Text("自助注册",style: TextStyle(fontSize: ScreenUtil().setSp(13),color: Colors.grey),textAlign: TextAlign.center),
                  ) ,
               ],
           ),
           SizedBox( height: ScreenUtil().setWidth(30),),
           InkWell(
             onTap: (){
               if((account.isEmpty &&account.length < 11)){
                  return;
               }else if(password .isEmpty&&password.length<6){
                  return;
               }
                Navigator.push(
                  context,
                  new MaterialPageRoute(
                    builder: (context) => new HomePage(),
                  ),
                );
             },
             child: Container(
                 decoration: BoxDecoration(
                   color:Color(0xff41A5EE),
                 ),
                 width: ScreenUtil().setWidth(320),
                 height: ScreenUtil().setWidth(44),
                 child:Center(
                   child: Text("安全登录",style: TextStyle(fontSize: ScreenUtil().setSp(17),color: Colors.white),textAlign: TextAlign.center,),
                 )
             ) ,
           ),
           SizedBox( height: ScreenUtil().setWidth(10),),
           InkWell(
             onTap: (){
               // Navigator.pop(context);
             },
             child: Container(
                 decoration: BoxDecoration(
                   color:Colors.white,
                 ),
                 width: ScreenUtil().setWidth(320),
                 height: ScreenUtil().setWidth(44),
                 child:Center(
                   child: Text("取消",style: TextStyle(fontSize: ScreenUtil().setSp(17),color:Color(0xff41A5EE)),textAlign: TextAlign.center,),
                 )
             ) ,
           ),
           SizedBox( height: ScreenUtil().setWidth(15),),
           Row(
             children: [
               SizedBox(width: ScreenUtil().setWidth(15),),
               // Container(width: ScreenUtil().setWidth(18),height: ScreenUtil().setWidth(18),color: Colors.blue,),
               IconButton(
                 icon: Icon(
                   Icons.check_box,
                   color: Colors.grey,
                   size: 24,
                 ),
                 onPressed: () {

                 },
               ),
               Text.rich(
                   TextSpan(
                       children: [
                         TextSpan(text: "《个人信息保护政策》",style: TextStyle(fontSize: ScreenUtil().setSp(14),color: Colors.blueAccent,),),
                       ]
                   )
               ),
               SizedBox(width: ScreenUtil().setWidth(20),),
               Container(
                 child:Text("记住登录号",style: TextStyle(fontSize: ScreenUtil().setSp(13),),textAlign: TextAlign.center,),
               ),
               Container(
                 child:  Switch(
                     value: _switchValue1,
                     onChanged: (value) {
                       setState(() {
                         _switchValue1 = value;
                       });
                     }),
               )
             ],
           )

         ],
       ) ,
    );
  }
}
